package com.ken.elmssm.mapper;

import com.ken.elmssm.bean.Admin;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author ken
 */
public interface AdminMapper extends BaseMapper<Admin>{
    /**
     * 根据用户的账号和密码执行登录操作
     * @param admin
     * @return
     */
    @Select("select adminId,adminName,password,salt,headImage from admin where adminName=#{adminName}")
    public Admin login(Admin admin);

    /**
     *新增
     * @param object
     * @return
     */
    boolean add(Admin object);

    /**
     * 根据主键删除
     * @param id
     * @return
     */
    @Delete("delete from admin where adminId=#{adminId}")
    boolean deleteById(Integer id);

    /**
     *修改
     * @param object
     * @return
     */
    @Update("update admin set password=#{password},salt=#{salt},headImage=#{headImage} where adminId=#{adminId}")
    boolean edit(Admin object);

    /**
     * 根据主键查询
     * @param id
     * @return
     */
    @Select("select adminId,adminName,password,salt,headImage from admin where adminId=#{adminId}")
    Admin findById(Integer id);
}